package com.example.task1.ui.AllService.parking;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;

import com.example.task1.R;
import com.example.task1.base.BaseActivity;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class ParkingActivity extends BaseActivity {

    private BottomNavigationView parkingNav;
    private FragmentManager supportFragmentManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_parking);
        initView();
        supportFragmentManager = getSupportFragmentManager();
        supportFragmentManager.beginTransaction().add(R.id.fragment,new ParkingHomeFragment()).commit();
        parkingNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.home:
                        supportFragmentManager.beginTransaction().replace(R.id.fragment,new ParkingHomeFragment()).commit();
                        break;
                    case R.id.news:
                        supportFragmentManager.beginTransaction().replace(R.id.fragment,new ParkingNewsFragment()).commit();
                        break;
                    case R.id.user:
                        supportFragmentManager.beginTransaction().replace(R.id.fragment,new ParkingUserFragment()).commit();
                        break;
                }
                return true;
            }
        });
    }

    @Override
    public String getMyTitle() {
        return "停车服务";
    }

    private void initView() {
        parkingNav = (BottomNavigationView) findViewById(R.id.parking_nav);
    }
}